"use strict";
exports.__esModule = true;
exports.getEnv = exports.getPath = void 0;
var path_1 = require("path");
var fs_1 = require("fs");
function getPath(url) {
    return (0, path_1.join)(__dirname, '../', url);
}
exports.getPath = getPath;
function getEnv(mode) {
    var envFilePath = getPath("/.env." + mode);
    var data = (0, fs_1.readFileSync)(envFilePath).toString();
    var res = {};
    data.split('\n').forEach(function (line) {
        var keyValueArr = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/);
        if (keyValueArr != null) {
            var key = keyValueArr[1];
            var value = keyValueArr[2] || '';
            var len = value ? value.length : 0;
            if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') {
                value = value.replace(/\\n/gm, '\n');
            }
            value = value.replace(/(^['"]|['"]$)/g, '').trim();
            res[key] = value;
        }
    });
    return res;
}
exports.getEnv = getEnv;
